<?php include "lang.php"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <?php include "import.php"; ?>
        <title>Gia An</title>
    </head>
    <body onunload="unloadP('productPageScroll')" onload="loadP('productPageScroll')">
        <?php include("floating-panel.php"); ?>
        <div class="wrapper">
            <?php include("header.php"); ?>  
            <div class="main_body">
                <?php include("left_menu.php"); ?>
                <div class="main_content">
                    <div class="main_content_header"><?php echo $langs['product.product'] ?></div>
                    <?php
                    include("../action/productAction.php");
                    if (!isset($_REQUEST['id'])) {
                        // Redirect to home page if there is no 'id' param in the header
                        printf("<script>location.href='index.php'</script>");
                    }
                    $product = mysql_fetch_array(getProduct($_REQUEST['id']));
                    $images = getImageOfProduct($_REQUEST['id']);
                    $firstImage = mysql_fetch_array($images);
                    ?>
                    <div class="image_box detail">	
                        <img src="../images/product/PRO_<?php echo $product['PRO_ID'] . "/" . ($firstImage ? $firstImage['IMG_PATH'] : '../images/cat/noimg.jpg') ?>" width="180" height="180"/>
                    </div>
                    <div class="detail_text">
                        <span class="name"><?php echo $product['PRO_NAME_' . $lang] . ' ' ?></span>(<?php echo $langs['product.instore'] ?>)<br/>
                        <span class="price"><?php echo number_format($product['PRO_PRICE'], 0, ",", ".") ?> <sup>VND</sup></span><br/>
                        <hr class="detail_hr"/>
                        <a onclick='addToCart(<?php echo $product['PRO_ID'] ?>, 1)' class="button right clear"><?php echo $langs['home.order'] ?></a>
                        <span class="description"><?php echo $product['PRO_DESCRIPTION_' . $lang] ?></span>
                    </div>
                    <div class="images_header"><?php echo $langs['product.detailImage'] ?></div>

                    <?php
                    echo "<div id='imageViewer'>";
                    echo '<div class="image_box small_box">';
                    echo '<a href="../images/product/PRO_' . $product['PRO_ID'] . "/" . $firstImage['IMG_PATH'] . '"><img src="../images/product/PRO_' . $product['PRO_ID'] . "/" . $firstImage['IMG_PATH'] . '" width="137" height="136"/></a>';
                    echo '</div>';
                    while ($image = mysql_fetch_array($images)) {
                        if ($image['IMG_PATH'] != "") {
                            echo '<div class="image_box small_box">';
                            echo '<a href="../images/product/PRO_' . $product['PRO_ID'] . "/" . $image['IMG_PATH'] . '"><img src="../images/product/PRO_' . $product['PRO_ID'] . "/" . $image['IMG_PATH'] . '" width="137" height="136"/></a>';
                            echo '</div>';
                        }
                    }
                    echo "</div>";
                    ?>
                </div>
            </div>
        </div>
        <?php
        include("footer.php");
        ConnectionManager::getInstance()->closeConnection();
        ?>
    </body>
</html>
